@{
    ViewBag.Title = "Hash计算 MD5、SHA1、SHA224、SHA-256、SHA384、SHA512计算";
    ViewBag.keywords = "Hash计算,MD5计算,SHA1计算,SHA-256计算,SHA512计算,哈希";
    ViewBag.description = "在线Hash计算工具,MD5计算,SHA1计算,SHA-256计算,SHA512计算,哈希";var host = Appsettings.app("BaseFile:HostUrl");
}
<div class="layui-row layui-form layui-form-pane hashcode">
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">内容：</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" id="content" name="content" rows="8" lay-verify="required" autocomplete="off" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-col-xs2">
            <select id="select_algo" class="layui-input">
                <option value="MD5">MD5</option>
                <option value="SHA1">SHA1</option>
                <option value="SHA224">SHA224</option>
                <option value="SHA256">SHA256</option>
                <option value="SHA384">SHA384</option>
                <option value="SHA512">SHA512</option>
                <option value="Hmac-MD5">Hmac-MD5</option>
                <option value="Hmac-SHA1">Hmac-SHA1</option>
                <option value="Hmac-SHA224">Hmac-SHA224</option>
                <option value="Hmac-SHA256">Hmac-SHA256</option>
                <option value="Hmac-SHA384">Hmac-SHA384</option>
                <option value="Hmac-SHA512">Hmac-SHA512</option>
            </select>
        </div>
        <div class="layui-col-xs2"><input id="input_key" class="layui-input" placeholder="密钥,非必填"></div>
        <div class="layui-col-xs4">
            <a class="layui-btn enc">计算</a>
            <a class="layui-btn layui-btn-danger cle">清空</a>
            <a class="layui-btn layui-btn-primary copy">复制结果</a>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">输出：</label>
        <div class="layui-input-block">
            <textarea placeholder="输出内容" id="outtxt" name="outtxt" rows="8" autocomplete="off" class="layui-textarea"></textarea>
        </div>
    </div>
</div>
@section Scripts{<script src="@host/lib/hash/crypto-js.min.js"></script>
<script type="text/javascript">
     layui.config({ base: '@host/js/' }).use('common',function(){  $=layui.jquery;var HashCode=layui.HashCode;let area_input = document.getElementById('content');let area_output = document.getElementById('outtxt');
    $(".hashcode .enc").bind("click", function () {
        var code = area_input.value;
        if (code === undefined || code === '' || code === null) { layer.msg("内容不能为空.", { icon: 2 }); return; }
        let key = document.getElementById('input_key');
        let algo = document.getElementById('select_algo');
        area_output.value = HashCode.calHash(area_input, algo, key);
    });
    $(".hashcode #select_algo").bind("change", function () {
        var code = area_input.value;
        if (code === undefined || code === '' || code === null) { layer.msg("内容不能为空.", { icon: 2 }); return; }
        let key = document.getElementById('input_key');
        let algo = document.getElementById('select_algo');
        area_output.value = HashCode.calHash(area_input, algo, key);
    });
    });
</script>
}
